package com.study.spmongodb.book.wwj.char15;

/**
 * @author MI
 * @version 1.0
 * @date 2020/11/28 10:40
 */
public interface TaskLifecycle<T> {

    //任务启动时会触发onStart
    void onStart(Thread thread);

    //任务运行时会触发onRunning 方法
    void onRunning(Thread thread);

    //任务结束时会触发
    void onFinish(Thread thread, T result);

    void onError(Thread thread, Exception e);

    public class EmptyLifecycle<T> implements TaskLifecycle<T> {
        @Override
        public void onStart(Thread thread) {

        }

        @Override
        public void onRunning(Thread thread) {

        }

        @Override
        public void onFinish(Thread thread, T result) {

        }

        @Override
        public void onError(Thread thread, Exception e) {

        }
    }

}
